﻿<%@ WebHandler Language="C#" Class="HandlerTestTest" %>

using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;

public class HandlerTestTest : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        string searchText = "開箱";

        using (UboxContext db = new UboxContext())
        {
            var items = from p in db.unboxing_article 
                        where p.unboxing_article_title.Contains(searchText)
                        select p.unboxing_article_id;
            context.Response.ContentType = "application/json";                     //轉型 把陣列轉成Json格式來回傳
            context.Response.Write(JsonConvert.SerializeObject(items));
        }
        
        
        
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}